describe("Time", function() {

    describe("minus", function() {
        it("should be able to subtract 2 times", function() {
            var t1 = Time.fromString('12:00')
            var t2 = Time.fromString('10:00')

            var result = t1.minus(t2);
            expect(result.toString()).toEqual('02:00');

            result = Time.fromString('12:11').minus(Time.fromString('10:22'));
            expect(result.toString()).toEqual('01:49');

            result = Time.fromString('12:10').minus(Time.fromString('13:11'));
            expect(result.toString()).toEqual('-01:01');
        });
    });

    describe("plus", function() {
        it("should be able to add 2 times", function() {
            var result = Time.fromString('12:00').plus(Time.fromString('10:00'))
            expect(result.toString()).toEqual('22:00');

            result = Time.fromString('12:00').plus(Time.fromString('10:00'))
            expect(result.toString()).toEqual('22:00');

            result = Time.fromString('-00:10').plus(Time.fromString('01:00'));
            expect(result.toString()).toEqual('00:50');
        });
    });

    describe("now", function() {
        it("should return a valid time", function() {
            var now = Time.now();
            expect(Time.isTime(now.toString())).toBeTruthy();
        });
    });

    describe("fromString", function() {
        it("should throw exception on invalid times", function() {
            expect(function(){Time.fromString('1000')}).toThrow();
            expect(function(){Time.fromString('aa:bb')}).toThrow();
            expect(function(){Time.fromString('10:00')}).not.toThrow();
            expect(function(){Time.fromString('1:2')}).not.toThrow();
            expect(function(){Time.fromString('134:245')}).not.toThrow();
        });
    });

});
